home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / NeXT-Icons / next-icon@gun.com / bin / link-next-icon next >
Encoding:
Text File  |  1995-04-08  |  1.9 KB  |  88 lines

  1. #!/bin/sh
  2. # Rebuild .dir.tiff images for each folder.
  3. # Timothy Reed (c) 1995
  4. # treed@gun.com or next-icon-request@gun.com Sat Apr  8 14:01:15 EDT 1995
  5.  
  6. # Set DEBUG=YES in your environment to see output, or uncomment the
  7. # following line.
  8. # DEBUG=YES
  9.  
  10. PROG="`basename $0`"
  11.  
  12. for DIR in $* ; do
  13.     #
  14.     # Skip $x if it isn't a directory
  15.     if test ! -d "$DIR" ; then
  16.         if test -n "${DEBUG}" ; then
  17.             echo "$DIR is not a directory." >&2
  18.         fi
  19.         continue
  20.     #
  21.     # Skip $x if it's a rich text directory.
  22.     elif test "$DIR" = "*rtfd" ; then
  23.         if test -n "${DEBUG}" ; then
  24.             echo "$DIR is not an appropriate directory." >&2
  25.         fi
  26.         continue
  27.     fi
  28.     (
  29.         #
  30.         # Go into $DIR
  31.         cd "$DIR"
  32.         if test $? != 0 ; then
  33.             if test -n "${DEBUG}" ; then
  34.                 echo "Could not cd into $DIR." >&2
  35.             fi
  36.             continue
  37.         fi
  38.         #
  39.         # For each directory in $DIR.
  40.         for PKG in * ; do
  41.             #
  42.             # Skip $PKG if it isn't a directory.
  43.             if test ! -d "$PKG" ; then
  44.                 if test -n "${DEBUG}" ; then
  45.                     echo "${DIR}/$PKG is not a directory." >&2
  46.                 fi
  47.                 continue
  48.             #
  49.             # Skip $PKG if .dir.tiff is already there.
  50.             elif test -f ${PKG}/.dir.tiff -o -h ${PKG}/.dir.tiff ; then
  51.                 if test -n "${DEBUG}" ; then
  52.                     echo "${DIR}/$PKG/.dir.tiff already exists." >&2
  53.                 fi
  54.                 continue
  55.             fi
  56.             (
  57.                 #
  58.                 # Go into $PKG
  59.                 cd "${PKG}"
  60.                 #
  61.                 # Skip $PKG if cd $PKG failed.
  62.                 if test $? != 0 ; then
  63.                     if test -n "${DEBUG}" ; then
  64.                         echo "Could not cd into ${DIR}/$PKG." >&2
  65.                     fi
  66.                     continue
  67.                 fi
  68.                 #
  69.                 # Find the newest .tiff image.
  70.                 IMAGE="`ls -t *.tiff 2>/dev/null | head -1`"
  71.                 #
  72.                 # Skip $PKG if $IMAGE is empty
  73.                 if test -z "${IMAGE}" ; then
  74.                     echo "Could not find an image in ${DIR}/${PKG}." >&2
  75.                     continue
  76.                 fi
  77.                 echo "Linking ${DIR}/${PKG}/${IMAGE} to .dir.tiff" >&2
  78.                 ln -s "${IMAGE}" .dir.tiff
  79.                 if test $? != 0 ; then
  80.                     echo "Problem linking ${DIR}/${PKG}/${IMAGE} to .dir.tiff." >&2
  81.                     continue
  82.                 fi
  83.             )
  84.         
  85.         done
  86.     )
  87. done
  88.